package kr.co.cherryt.view;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.VideoView;

public class ResizableVideoView extends VideoView {

	private static boolean showFullScreenAlways = true;
	
	private int displayWidth;
	private int displayHeight;
	
	public ResizableVideoView(Context context) {
		super(context);
	}

	public ResizableVideoView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public ResizableVideoView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public void initDisplayMeasureInfo(int displayWidth, int displayHeight){
		this.displayWidth = displayWidth;
		this.displayHeight = displayHeight;
	}
	
	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		if(showFullScreenAlways == false){
			// default action. it remains the aspect ratio. 
			super.onMeasure(widthMeasureSpec, heightMeasureSpec);
			return;
		}
		else{
			// modified action. show the contents with full screen always.
			setMeasuredDimension(displayWidth, displayHeight);
			return;
		}
	}
}
